#ifndef __BSP_LCD_H__
#define __BSP_LCD_H__

#include <string.h>
#include "math.h"
#include "esp_err.h"
#include "esp_log.h"
#include "esp_check.h"
#include "i2c.h"
#include "driver/spi_master.h"
#include "esp_lcd_types.h"
#include "esp_lcd_panel_io.h"
#include "esp_lcd_panel_vendor.h"
#include "esp_lcd_panel_ops.h"
#include "esp_lcd_touch_ft5x06.h"
#include "lvgl_port.h"
#include "driver/ledc.h"
#include "pca9557.h"

/************************************************************
 *********************LCD 显示*******************************/

#define BSP_LCD_PIXEL_CLOCK_HZ              (80 * 1000 * 1000)
#define BSP_LCD_SPI_NUM                     (SPI3_HOST)
#define LCD_CMD_BITS                        (8)
#define LCD_PARAM_BITS                      (8)
#define BSP_LCD_BITS_PER_PIXEL              (16)
#define LCD_LEDC_CH                         LEDC_CHANNEL_0              //LCD背光PWM控制channel

#define BSP_LCD_H_PIX                       (320)                       //LCD屏幕高的像素
#define BSP_LCD_W_PIX                       (240)                       //LCD屏幕宽的像素


#define BSP_LCD_SPI_MOSI_PIN                    (GPIO_NUM_40)
#define BSP_LCD_SPI_CLK_PIN                     (GPIO_NUM_41)
#define BSP_LCD_SPI_CS_PIN                      (GPIO_NUM_NC)
#define BSP_LCD_DC_PIN                          (GPIO_NUM_39)
#define BSP_LCD_RST_PIN                         (GPIO_NUM_NC)
#define BSP_LCD_BACKLIGHT_PIN                   (GPIO_NUM_42)              //LCD背光控制引脚

//BSP_LCD_DRAW_BUF_HEIGHT是一次绘制的高度，此高度受芯片内存的限制，若lvgl的缓存放到外部PSRAM，这里可以定义为240，即全高度
//若没有放在PSRAM中，而是使用内部内存和DMA传输，这里就不能定义为240，因为内存不够。定义为20就可以，
#define BSP_LCD_DRAW_BUF_HEIGHT             (20)        

extern esp_err_t bsp_display_brightness_init(void);
extern esp_err_t bsp_display_brightness_set(int brightness_percent);
extern esp_err_t bsp_display_backlight_off(void);
extern esp_err_t bsp_display_backlight_on(void);
extern esp_err_t bsp_lcd_init(void);
extern void lcd_set_color(uint16_t color);
extern void bsp_lvgl_start(void);



#endif
